package com.huibei.wateradmin.controller;

import com.huibei.wateradmin.authority.util.DateUtil;
import com.huibei.wateradmin.common.message.PageDto;
import com.huibei.wateradmin.common.message.ReqAdminListMsg;
import com.huibei.wateradmin.merchant.message.ReqShopOrderMsg;
import com.huibei.wateradmin.order.feignclient.OrderFeignClient;
import com.huibei.wateradmin.order.message.ReqOrderList;
import com.huibei.wateradmin.order.message.model.AdminShopOrderModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/admin/order")
public class ShopOrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    @RequestMapping(value = "/listPage",method = RequestMethod.GET)
    public ModelAndView listPage() {
        ModelAndView mv = new ModelAndView("order/list");
        return mv;
    }


    @RequestMapping(value = "/list2",method = RequestMethod.POST)
    public PageDto<AdminShopOrderModel> getOrderList(@RequestBody ReqShopOrderMsg msg) {
        System.out.println("订单请求参数："+msg.toString()+"time:"+ DateUtil.dateToString(new Date(),"hh:MM:ss"));
        PageDto<AdminShopOrderModel> orderList = orderFeignClient.getAllOrders(msg);
        System.out.println(orderList.getTotalElements() + "----" + orderList.getTotalPages()+"time:"+ DateUtil.dateToString(new Date(),"hh:MM:ss"));
        return orderList;
    }

}
